#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
ll T, n, ans, a[N];
void dfs(ll dep, ll pre1, ll pre2, ll sum) {
    if (dep == n + 1) {
        ans = max(ans, sum);
        return;
    }
    if (pre1 == a[dep])dfs(dep + 1, a[dep], pre2, sum + a[dep]);
    else dfs(dep + 1, a[dep], pre2, sum);
    if (pre2 == a[dep])dfs(dep + 1, pre1, a[dep], sum + a[dep]);
    else dfs(dep + 1, pre1, a[dep], sum);
}
int main() {
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    scanf("%lld", &T);
    while (T--) {
        ans = 0;
        scanf("%lld", &n);
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &a[i]);
        }
        dfs(1, 0, 0, 0);
        printf("%lld\n", ans);
    }
    return 0;
}